<?php
require_once 'classes/Membership.php';
include('includes/confirm.php');
$membership = new Membership();
$page_name = account;
if(!empty($_POST['email'])){
$response = $membership->submit_user_data( $_SESSION['userid'],$_POST['firstname'], $_POST['lastname'], $_POST['midname'], $_POST['address'], $_POST['SYear'],$_POST['SMonth'],$_POST['SDay'],$_POST['phone'], $_POST['opwd'], $_POST['npwd'], $_POST['npwd2'], $_POST['email']);
} else {
$responce = "Must have an email";
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <?php include('includes/head.php'); ?>
<body onload="YYYYMMDDstart(document.form1,document.form1.SYear,document.form1.SMonth,document.form1.SDay),YYYYMMDDstart(document.form1,document.form1.EYear,document.form1.EMonth,document.form1.EDay)">
<div id="wrapper">
    <?php include('includes/header.php'); ?>
    <?php include('includes/menu.php'); ?>
    
  <div id="page">
    <!-- <div id="page-bgtop"> -->
     <!-- <div id="content"> -->
    <?php if(isset($response)) echo "<h4 class='alert'>" . $response . "</h4>"; ?>
	<?php
	$mysql = new Mysql();
	$stmt=$mysql->run_query("SELECT fname, lname, mi, email, address, phone, dob FROM user WHERE id='".$_SESSION['userid']."'");
	$stmt->bind_result($fname, $lname, $mi, $email, $address, $phone, $dob);
	$stmt->fetch();
	$stmt->close();
	?>
    <h2>Welcome: <?php echo $_SESSION['username'];?></h2>
    <div id="account">
            <form name=form1 method="post" action="">
               
                <p>
                    <label for="firstname">First Name: </label>
                    <input type="text" name="firstname" value="<?php print $fname; ?>" />
                </p>
                
                <p>
                    <label for="lastname">Last Name: </label>
                    <input type="text" name="lastname" value="<?php print $lname; ?>"/>
                </p>
                
                <p>
                    <label for="midname">Middle Name: </label>
                    <input type="text" name="midname" value="<?php print $mi; ?>"/>
                </p>
                
                <p>
                    <label for="address">Address: </label>
                    <input type="text" name="address" value="<?php print $address; ?>"/>
                </p>
                
                <p>
                    <label for="phone">Phone Number: </label>
                    <input type="text" name="phone" value="<?php print $phone; ?>"/>
                </p>
                
                <p>
                    <label for="email">Email Address: </label>
                    <input type="text" name="email" value="<?php print $email; ?>"/>
                </p>
                
                
                <p> 
				<?php $dob_a = explode("-",$dob); ?>
      <label for="DOB">Date of Birth: </label>
 　　 <select name=SYear onchange="YYYYDD(this.value,document.form1.SMonth,document.form1.SDay)">  
 　　 <option value="<?php print $dob_a[0]?>"><?php print $dob_a[0]?></option>  
 　　 </select>Year  
 　　 <select name=SMonth onchange="MMDD(this.value,document.form1.SYear,document.form1.SDay)">  
 　　 <option value="<?php print $dob_a[1]?>"><?php print $dob_a[1]?></option>  
 　　 </select>Month  
 　　 <select name=SDay>  
 　　 <option value="<?php print $dob_a[2]?>"><?php print $dob_a[2]?></option>  
 　　 </select>Date  
 　　<script language="JavaScript">  
 <!--  
 function YYYYMMDDstart(form,year,month,day)  
 　　{  
     　　 MonHead = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];  
     　　 //Year  
     　　 var y = new Date().getFullYear();  
     　　 for (var i = (y-30); i < (y+5); i++)
     　　 year.options.add(new Option(i,i));  
     　　 //Month 
     　　 for (var i = 1; i < 13; i++)  
     　　 month.options.add(new Option(i,i));  
     　　 yyear.value = y;  
     　　 month.value = new Date().getMonth() + 1;  
     　　 var n = MonHead[new Date().getMonth()];  
     　　 if (new Date().getMonth() ==1 && IsPinYear(year.options[year.selectedIndex].value)) n++;  
     　　 writeDay(n,day);
          //Date
     　　 day.value = new Date().getDate();  
 　　}  
 　　  
   
 function YYYYDD(str,month,day) //decide year
 　　{  
     　　 var MMvalue = month.options[month.selectedIndex].value;  
     　　 if (MMvalue == "" ){ var e = day; optionsClear(e); return;}  
     　　 var n = MonHead[MMvalue - 1];  
     　　 if (MMvalue ==2 && IsPinYear(str)) n++;  
     　　 writeDay(n,day)  
 　　}  
 　　  
   
 function MMDD(str,year,day) //Month 
 　　{  
 　　 var YYYYvalue = year.options[year.selectedIndex].value;  
 　　 if (YYYYvalue == "" ){ var e = day; optionsClear(e); return;}  
 　　 var n = MonHead[str - 1];  
 　　 if (str ==2 && IsPinYear(YYYYvalue)) n++;  
 　　 writeDay(n,day)  
 　　}  
 　　function writeDay(n,day) //Date 
 　　{  
 　　 var e = day; optionsClear(e);  
 　　 for (var i=1; i<(n+1); i++)  
 　　 e.options.add(new Option(i,i));  
 　　}  
 　　function IsPinYear(year) 
 　　{ return(0 == year%4 && (year%100 !=0 || year%400 == 0));}  
 　　function optionsClear(e)  
 　　{  
 　　 for (var i=e.options.length; i>0; i--)  
 　　 e.remove(i);  
 　　}  
 　　//-->
 </script>  	
                </p>
					Change Password:
				<p>
                    <label for="opwd">Current Password: </label>
                    <input type="password" name="opwd"  />
                </p>
				
				<p>
                    <label for="npwd">New Password: </label>
                    <input type="password" name="npwd"  />
                </p>
                
                <p>
                    <label for="npwd2">Reenter New Password: </label>
                    <input type="password" name="npwd2" />
                </p>
				
                <p>
                    <input class="submit" type="submit" id="submit" value="Submit" name="submit" />                    
                </p>
            </form>
        </div><!--end login-->
        
        
      </div>
      <!-- end div#content -->
      
      <!--<div style="clear: both; height: 1px"></div>
	  
    </div> -->
  </div> 
  <!-- end div#page -->
    <?php include('includes/footer.php'); ?>
</div> <!-- end div#wrapper -->
</body>
</html>
